import { Application } from 'egg'
import { Models } from 'sequelize'

export default (app: Application) => {
  const { UUID, UUIDV4, STRING } = app.Sequelize.DataTypes
  /** 城市 */
  const model = app.model.define('cities', {
    id: { type: UUID, defaultValue: UUIDV4, primaryKey: true },
    /** 城市英文名或拼音 */
    name: { type: STRING, unique: true },
    /** 城市中文名 */
    title: STRING,
    /** 国家名 可关联到 country.name */
    country: STRING,
    /** 省 可关联到 province.name */
    province: STRING,
  })

  model.associate = (models: Models) => {
    //
    app.logger.info('model/city.associate', models)
  }

  return model
}
